<template>
  <div class="collect">
    <van-nav-bar title="收藏" fixed placeholder></van-nav-bar>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="getData"
    >
      <ArticleItem
        v-for="item in list"
        :key="item.id"
        :item="item"
      ></ArticleItem>
    </van-list>
  </div>
</template>
<script>
import { interviewOptList } from '@/api/collect'
export default {
  data () {
    return {
      list: [],
      loading: false,
      finished: false,
      query: {
        optType: 2,
        pageSize: 10,
        page: 1
      }
    }
  },
  created () {
    // this.getData()
  },
  methods: {
    async getData () {
      const res = await interviewOptList(this.query)
      // 1:将v-model的值改成false
      this.loading = false
      // 2:数据累加
      this.list.push(...res.data.rows)
      // 3:页码++
      this.query.page++
      // 4:判断是否完成，如果完成finished=true
      if (this.list.length >= res.data.total) {
        this.finished = true
      }
      console.log(res)
    }
  }
}
</script>
<style></style>
